<div class="row">
  <div class="col-xs-12">
    <%= render partial: 'common/nav', locals: {show_tab: :index, model_nav_name: :admin_article, pjax: true} %>
    <%= form_for 'Article', url: admin_articles_destroy_multi_path, method: :post, data: {confirm: "#{  t 'common.confirm_delete'}"} do %>
        <button class="btn btn-minier btn-danger" type="submit">
          <i class="icon-trash"></i> <%= t 'common.delete_multi' %></button>
        <div id="admin_articles">
          <%= grid(@articles, show_filters: :when_filtered) do |g|
            g.action_column param_name: :select_ids, object_property: :id
            g.column name: "#{t 'activerecord.attributes.defaults.id'}", attribute: 'id', filter: false, ordering: true
            g.column name: "#{t 'activerecord.attributes.article.publisher'}", attribute: 'publish_id' do |c|
              c.publisher.name if c.publisher.present?
            end
            g.column name: "#{t 'activerecord.attributes.article.content'}", attribute: 'content'
            g.column name: "#{t 'activerecord.attributes.article.praise_num'}", attribute: 'praise_num'
            g.column name: "#{t 'activerecord.attributes.article.comment_num'}", attribute: 'comment_num'
            g.column name: "#{t 'activerecord.attributes.article.state'}", attribute: 'state' do |c|
              {'0'=>'不展示','-1'=>'删除','1'=>'展示' }[c.state.to_s]
            end

            g.column do |c|
              grid_operator(:admin_article_path, c.id)
            end
          end %>
        </div>

    <% end %>
  </div>
</div>

<script>
  $(function () {
    $('.nav.nav-list li.active').removeClass('active');
    $('.nav.nav-list li[data-model="article_list"]').addClass('active');
  });
</script>